const { DataTypes } = require('sequelize');
const sequelize = require('../db.js');
const User = require('./users');
const Content = require('./content')

const Comment = sequelize.define('comment', {
  id: {
    type: DataTypes.BIGINT(10),
    primaryKey: true,
    autoIncrement: true
  },
  detail: {
    type: DataTypes.STRING,
    allowNull: false
  }
},{
  tableName: 'comment'
});

// 评论人
User.hasMany(Comment);
Comment.belongsTo(User);

// 关联内容表，也就是此评论属于哪条内容
Content.hasMany(Comment);
Comment.belongsTo(Content);

module.exports = Comment;